var express = require('express');
var interface = require('./interface.js');
var db = require('./db.js')
var router = express.Router();

/* GET home page. */
router.get('/allPage', function(req, res, next) {
	let sql = "SELECT * FROM t_person";
	db.query(sql, (err, results) => {
		res.json({code: 200, data: results, msg: '成功'})
	})
});

router.post('/page', function(req, res, next) {
	interface.getPerson(db, req, res)
});

router.post('/update', function(req, res, next) {
	interface.updatePerson(db, req, res)
});

router.post('/add', function(req, res, next) {
	interface.addPerson(db, req, res)
});

router.get('/delete', function(req, res, next) {
	interface.deletePerson(db, req, res)
});

router.get('/detail', function(req, res, next) {
	interface.detailPerson(db, req, res)
});

module.exports = router;
